﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestClasse
{
    class Program
    {
        static void Main(string[] args)
        {
            var measure = new MeasureSize<DataHelper.BLL.News>(() => new DataHelper.BLL.News());
            long zise=  measure.GetByteSize();
            var lst =  DataHelper.BLL.BK_BookingDetail.BK_BookingDetailSelectAll("",1,20);
            var lst1 = DataHelper.BLL.BK_Booking.BK_BookingSelectAll("",1,20);
            var lst2 = DataHelper.BLL.BK_Order.BK_OrderSelectAll("",1,20);
            var lst3 = DataHelper.BLL.BK_Passenger.BK_PassengerSelectAll("",1,20);
            var lst4 = DataHelper.BLL.BK_Ticket.BK_TicketSelectAll("",1,20);
            var lst5 = DataHelper.BLL.Comments.CommentSelectAll("",1,20);
            var lst6 = DataHelper.BLL.EmailRecive.EmailReciveSelectAll("",1,20);
            var lst7 = DataHelper.BLL.News.NewsSelectAll("",1,20);
            var lst8 = DataHelper.BLL.SEO.SEOSelectAll("",1,20);
            var lst9 = DataHelper.BLL.Setting.SettingSelectAll("",1,20);
            var lst10 = DataHelper.BLL.TK_Country.TK_CountrySelectAll("",1,20);
            var lst11 = DataHelper.BLL.TK_Firm.TK_FirmSelectAll("",1,20);
            var lst12 = DataHelper.BLL.TK_Station.TK_StationSelectAll("",1,20);
            var lst13 = DataHelper.BLL.UserProfile.UserProfileSelectAll("",1,20);
            var lst14 = DataHelper.BLL.webpages_Membership.webpages_MembershipSelectAll("",1,20);
            var lst15 = DataHelper.BLL.webpages_OAuthMembership.webpages_OAuthMembershipSelectAll("",1,20);
            var lst16 = DataHelper.BLL.webpages_Roles.webpages_RolesSelectAll("",1,20);
            var lst17 = DataHelper.BLL.webpages_UsersInRoles.webpages_UsersInRolesSelectAll("",1,20);
            
        }
    }

    public class MeasureSize<T>
    {
        private readonly Func<T> _generator;
        private const int NumberOfInstances = 10000;
        private readonly T[] _memArray;

        public MeasureSize(Func<T> generator)
        {
            _generator = generator;
            _memArray = new T[NumberOfInstances];
        }

        public long GetByteSize()
        {
            //Make one to make sure it is jitted
            _generator();

            long oldSize = GC.GetTotalMemory(false);
            for (int i = 0; i < NumberOfInstances; i++)
            {
                _memArray[i] = _generator();
            }
            long newSize = GC.GetTotalMemory(false);
            return (newSize - oldSize) / NumberOfInstances;
        }
    }
}
